<template>
    <div class="order">
        <headView></headView>
        <div class="mbx">
            <p>首页</p>
            <span>></span>
            <p>购物车</p>
            <span>></span>
            <p>填写订单</p>
        </div>
        <div class="box">
            <h3>收货地址</h3>
            <div class="address">
                <p class="ar1">
                    <span>收货人：{{ data.userAddresses[0].receiver }}</span>
                    <span>联系方式：{{ data.userAddresses[0].contact }}</span>
                    <span>收货地址：{{ data.userAddresses[0].fullLocation }}</span>
                </p>
                <p class="ar2">
                    修改地址
                </p>
                <p class="ar3">
                    <span>切换地址</span>
                    <span>添加地址</span>
                </p>
            </div>
            <h3>商品信息</h3>
            <div class="body-box">
                <div class="header">
                    <p class="h-dic">商品信息</p>
                    <p class="h-price">单价</p>
                    <p class="h-num">数量</p>
                    <p class="h-nowprice">小计</p>
                    <p class="h-change">实付</p>
                </div>
                <div class="body_item" v-for="item in data.goods" :key="item.id">
                    <div class="item-img">
                        <img :src="item.picture" alt="" class="img">
                        <div class="dic">
                            <p>{{ item.name }}</p>
                            <span>{{ item.attrsText }}</span>
                        </div>
                    </div>
                    <p class="price">{{ item.price }}</p>
                    <p class="num">{{ item.count }}</p>
                    <p class="nowPrice">￥{{ item.totalPrice }}</p>
                    <p class="totalPrice">￥{{ item.totalPayPrice }}</p>
                </div>
            </div>
            <h3>配送时间</h3>
            <div class="ps">
                <span>不限送货时间：周一至周日</span>
                <span>工作日送货：周一至周五</span>
                <span>双休日、假日送货：周一至周五</span>
            </div>
            <h3>支付方式</h3>
            <div class="zf">
                <span>在线支付</span>
                <span>货到付款</span>
            </div>
            <h3>金额明细</h3>
            <p class="mx">
                <span><span>商品件数：</span><span>{{ data.summary.goodsCount }}件</span></span>
                <span><span>商品总价：</span><span>￥{{ data.summary.totalPrice }}</span></span>
                <span><span>运费：</span><span>{{ data.summary.postFee }}</span></span>
                <span><span>应付金额：</span><span class="color">￥{{ data.summary.totalPayPrice }}</span></span>
            </p>
            <button class="btn" @click="toPay(data.summary.totalPayPrice)">提交订单</button>
        </div>
    </div>
</template>

<script>
import headView from "../../components/HeadView.vue";
export default {
    name: "OrderView.vue",
    components: {
        headView,
    },
    data() {
        return {
            data: [],
        }
    },
    created() {
        this.$api.getOrder().then(res => {
            console.log(res.data.result)
            this.data = res.data.result
        })
    },
    methods: {
        toPay(total) {
            this.$router.push({ path: "/pay", query: { val: total } })
        }
    }

}
</script>

<style lang="scss" scoped>
.order {
    background: #eee;
    overflow: hidden;
}

.mbx {
    width: 1240px;
    height: 70px;
    margin: 0 auto;
    display: flex;
    align-items: center;

    span {
        margin: 0 10px;
        color: #aaa;
    }
}

.box {
    width: 1240px;
    margin: 0 auto 20px;
    padding: 0 20px;
    box-sizing: border-box;
    position: relative;
    padding-bottom: 100px;
    background: #fff;

    h3 {
        width: 100%;
        height: 70px;
        font-size: 16px;
        font-weight: 400;
        line-height: 70px;
        padding-left: 10px;
        border-bottom: 1px solid #f5f5f5;
    }

    .address {
        width: 100%;
        height: 170px;
        display: flex;
        align-items: center;

        .ar1 {
            width: 618px;
            height: 130px;
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            padding-left: 20px;
        }

        .ar2 {
            width: 160px;
            color: #27ba9b;
            text-align: center;

        }

        .ar3 {
            width: 420px;
            display: flex;
            text-align: center;
            justify-content: center;

            span {
                display: block;
                width: 140px;
                height: 46px;
                line-height: 46px;
                border: 1px solid #eee;
                margin: 0 10px;
            }
        }
    }

    .header {
        display: flex;
        height: 70px;
        text-align: center;
        line-height: 70px;
        background: #eee;

        .h-dic {
            width: 400px;
        }

        .h-price {
            width: 220px;
        }

        .h-num {
            width: 180px;
        }

        .h-nowprice {
            width: 180px;
        }

        .h-change {
            width: 140px;
        }
    }

    .body-box {
        display: flex;
        flex-direction: column;
        background: #fff;

        .body_item {
            display: flex;
            text-align: center;
            align-items: center;
            margin: 20px 0;

            .item-img {
                width: 400px;
                display: flex;
                padding-left: 20px;
                box-sizing: border-box;

                .img {
                    width: 100px;
                    height: 100px;
                    margin-right: 10px;
                }

                .dic {
                    display: flex;
                    flex-direction: column;
                    justify-content: space-around;
                    align-items: flex-start;
                    text-align: start;

                    span {
                        color: #999;
                    }
                }
            }

            .price {
                width: 220px;
            }

            .num {
                width: 180px;
                padding: 0 20px;
                box-sizing: border-box;
                display: flex;
                justify-content: space-around;
            }

            .nowPrice {
                width: 180px;
            }

            .totalPrice {
                width: 140px;
            }
        }
    }

    .ps {
        display: flex;
        height: 90px;
        align-items: center;

        span {
            display: block;
            width: 228px;
            height: 46px;
            line-height: 46px;
            border: 1px solid #eee;
            margin: 0 10px;
            text-align: center;
        }
    }

    .zf {
        display: flex;
        height: 90px;
        align-items: center;

        span {
            display: block;
            width: 228px;
            height: 46px;
            line-height: 46px;
            border: 1px solid #eee;
            margin: 0 10px;
            text-align: center;
        }
    }

    .mx {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: flex-end;
        padding-right: 20px;

        >span {
            display: flex;
            height: 50px;
            justify-content: flex-end;
            font-size: 14px;
            width: 200px;
            justify-content: space-between;

            .color {
                color: #cf4444;
                font-size: 18px;
            }
        }
    }

    .btn {
        width: 180px;
        height: 50px;
        border: 0;
        background: #27ba9b;
        color: #fff;
        font-size: 16px;
        position: absolute;
        right: 20px;
    }
}
</style>